import { Crypto, Base64} from "./crypto.js"
import { fileName} from "@/utils/utils.js"
export const aliOssParams = (oss_aid,oss_aky,expiration,oss_securityToken,oss_host,file_type='mp4',path="video/edu/") =>
{
	console.log(oss_aid,oss_aky,expiration,oss_securityToken,oss_host);
	
	if(!oss_aid || !oss_aky || !expiration || !oss_securityToken){
		return false;
	}
    var s_aid = oss_aid;//你自己的阿里云的accessid
    var s_aky = oss_aky;//你自己的阿里云的accesskey
    var policyText = {
      "expiration": expiration,//上传的文件失效日期自己定义
      "conditions": [
        ["content-length-range", 0, 10485760000]//上传的内容大小，自己定义
      ]
    };
	
	var policy = Base64.encode(JSON.stringify(policyText));//生成的加密策略
	    var bytes = Crypto.util.HMAC(Crypto.util.SHA1, policy, s_aky, { asBytes: true });
	    var signature = Crypto.util.bytesToBase64(bytes);//生成的签名
	var _fileName = fileName(path,file_type);
    return {
      policy: policy,
      signature: signature,
      aid: s_aid,
	  securityToken:oss_securityToken,
	  fileName:_fileName,
	  host:oss_host
    }
}
 

 
